package com.applet.utils.common;

public class VeriCodeUtils {

	private static final String MESSAGE_SCOPE = "0123456789";

	public static String getMessageCode(int length) {

		StringBuffer tempB = new StringBuffer(length);
		final int charOfMassegeLength = MESSAGE_SCOPE.length();
		for (int i = 0; i < length; i++) {
			double d = Math.random();
			int index = (int) (Math.floor(d * charOfMassegeLength) / 1);
			tempB.append(MESSAGE_SCOPE.charAt(index));
		}
		return tempB.toString();
	}

	public static void main(String[] args){
		System.out.println(getMessageCode(4));
	}
}
